﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OutOrderAdd.aspx.cs" Inherits="ZCZP.Web.Site.OutSource.OutOrderAdd" MasterPageFile="~/MastePage/SubEmptyMaster.Master" ValidateRequest="false" %>

<%@ MasterType VirtualPath="~/MastePage/SubEmptyMaster.Master" %>
<%@ Register Assembly="OneSoft.Web" Namespace="OneSoft.Web.UI.WebControls" TagPrefix="asp" %>
<%@ Register Assembly="BySoft.Web.Controls" Namespace="BySoft.Web.Controls" TagPrefix="cc1" %>

     
   

<asp:Content ContentPlaceHolderID="EmptyMasteCPH" runat="server" ID="cphContent">
    

    <script language="javascript" type="text/javascript">
        $(function () {
            $("#tabs").tabs({ show: function (event, ui) { iframeAutoFit(); } });
            $("#<%=txtIsFinish.ClientID%>").hide();
        });
        function Refreashtab() {
            $("#tabs").tabs({ show: function (event, ui) { iframeAutoFit(); } });
        }

        function CheckNumWithDotOne(txtBox) {
            if (txtBox != null && txtBox.value != "") {
                var numFormat = /(^(\-?)[0-9]\d{0,9}(\.\d{0,2})?$)/;
                var text = txtBox.value;
                if (!numFormat.test(text)) {
                    txtBox.value = 0;
                }
            }
        }

        function CheckNumWithOutminus(txtBox) {
            if (txtBox != null && txtBox.value != "") {
                var numFormat = /^\d*$/;
                var text = txtBox.value;
                if (!numFormat.test(text)) {
                    txtBox.value = 0;
                }
            }
        }

        //厂商回调
        function FillSupplierPack() {
            var str = getCookie(dialogReturn_key);
            if (str != null && str != "") {
                str = decodeURIComponent(str);
                var arrTmp = str.split(",");
                if (undefined != arrTmp[0]) {
                    document.getElementById("<%=hidSupplierID.ClientID%>").value = arrTmp[0];
                }
                if (undefined != arrTmp[1]) {
                    document.getElementById("<%=txtSupplierName.ClientID%>").value = arrTmp[1];
                }


                $("#<%=btnSelectSupplier.ClientID %>").click();
            }
            setCookie(dialogReturn_key, "");
        }

        function OpenProcessID() {
            ShowTopDialog('工序选择', '../ComPage/QuerySOutProcess.aspx', 'FillOutProcessID();', 1000, 500); return false;
        }
        //工序回调
        function FillOutProcessID() {
            /*
             m_strResult = string.Format(@"{0},{1}", strProcessID, strScheduleDetailID, 
                            lblWorkOrderNo.Text, lblProcessName.Text,lblScheduleNum.Text);
            */
            var str = getCookie(dialogReturn_key);
            if (str != null && str != "") {
                
                str = decodeURIComponent(str);
                var arrTmp = str.split(",");
                if (undefined != arrTmp[0]) {
                    document.getElementById("<%=hidOutProcessID.ClientID%>").value = arrTmp[0];

                }
                if (undefined != arrTmp[1]) {
                    document.getElementById("<%=hdScheduleDetailID.ClientID%>").value = arrTmp[1];
                }
                if (undefined != arrTmp[2]) {
                    document.getElementById("<%=txtScheduleID.ClientID%>").value = arrTmp[2];
                }
                if (undefined != arrTmp[3]) {
                    document.getElementById("<%=txtWorkOrderNo.ClientID%>").value = arrTmp[3];
                }
                if (undefined != arrTmp[4]) {
                    document.getElementById("<%=txtOutProcessName.ClientID%>").value = arrTmp[4];
                }
                if (undefined != arrTmp[5]) {
                    document.getElementById("<%=txtBackNums.ClientID%>").value = arrTmp[5];
                }


                $("#<%=btnSelectOutProcessID.ClientID %>").click();

            }
            setCookie(dialogReturn_key, "");
        }

        function FillBackMaterialID() {

            var str = getCookie(dialogReturn_key);
            if (str != null && str != "") {
                str = decodeURIComponent(str);
                <%--var arrTmp = str.split(",");
                if (undefined != arrTmp[0]) {
                    document.getElementById("<%=hidBackMaterialID.ClientID%>").value = arrTmp[0];
                }
                if (undefined != arrTmp[1]) {
                    document.getElementById("<%=txtBackMaterialName.ClientID%>").value = arrTmp[1];
                }--%>

                $("#<%=btnSelectBackMaterial.ClientID %>").click();
            }
            setCookie(dialogReturn_key, "");
        }
       
    </script>
    <h1 class="tit">委协 >> <a href="OutOrderList.aspx">委外指令单</a> >> 新增</h1>
    <div class="tableStyle2">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <table cellpadding="0" cellspacing="0" id="tBase" runat="server">
                    <tr>
                        <th width="20%">指令单号：
                        </th>
                        <td width="30%">
                            <asp:TextBox ID="lblBillID" runat="server" MaxLength="100" CssClass="text ui-widget-content ui-corner-all"
                                ReadOnly="true"></asp:TextBox>
                        </td>
                        <th>日期</th>
                        <td>
                            <input type="text" id="cpBillDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"
                                readonly="true" style="width: 85px" class="Wdate" runat="server" />
                            <span style="color: Red">*</span>
                            <asp:RequiredFieldValidator ID="rfvBillDate" runat="server" ErrorMessage="请输入日期！"
                                ControlToValidate="cpBillDate" Display="None" ValidationGroup="gSubmit">
                            </asp:RequiredFieldValidator></td>
                    </tr>

                    <tr>
                        <th width="20%">委外厂商：
                        </th>
                        <td width="30%">

                            <asp:HiddenField ID="hidSupplierID" runat="server" />
                            <asp:TextBox ID="txtSupplierName" runat="server" MaxLength="50" ReadOnly="true" CssClass="text ui-widget-content ui-corner-all"
                                Width="90%"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvSupplierName" runat="server" ErrorMessage="请选择厂商！"
                                ControlToValidate="txtSupplierName" Display="None" ValidationGroup="gSubmit">
                            </asp:RequiredFieldValidator>
                            <span style="color: Red">*</span>
                            <a href="#" onclick="ShowTopDialog('厂商选择', '../ComPage/QuerySOutSupplierByName.aspx','FillSupplierPack();',1000,650);return false;">
                                <img src="../App_Themes/Common_CSS/images/GridDetail.gif" alt="" /></a>

                            <asp:Button ID="btnSelectSupplier" runat="server" CssClass="Hidden" OnClick="btnSelectSupplier_Click" />

                        </td>
                        <th width="20%">委外工序：
                        </th>
                        <td width="30%">
                            <asp:HiddenField ID="hdScheduleDetailID" Value='<%#Eval("ScheduleDetailID") %>' runat="server" />
                            <asp:HiddenField ID="hidOutProcessID" runat="server" />
                            <asp:TextBox ID="txtOutProcessName" runat="server" MaxLength="50" ReadOnly="true" CssClass="text ui-widget-content ui-corner-all"></asp:TextBox>
                              <asp:RequiredFieldValidator ID="rfvOutProcessID" runat="server" ErrorMessage="请选择工序！"
                                ControlToValidate="txtOutProcessName" Display="None" ValidationGroup="gSubmit">
                            </asp:RequiredFieldValidator>

                            <asp:Button ID="btnSelectOutProcessID" runat="server" CssClass="Hidden" OnClick="btnSelectOutProcessID_Click" />

                            <span style="color: Red">*</span>
                            <a onclick="OpenProcessID();">
                                <img src="../App_Themes/Common_CSS/images/GridDetail.gif" alt="" /></a>
                        </td>
                    </tr>
                    <tr>
                        <th width="20%">制造号码：
                        </th>
                        <td width="30%">
                            <asp:TextBox ID="txtWorkOrderNo" ReadOnly="true" runat="server" MaxLength="50" CssClass="text ui-widget-content ui-corner-all"></asp:TextBox>
                        </td>
                        <th width="20%">排程单号：
                        </th>
                        <td width="30%">
                            <asp:TextBox ID="txtScheduleID" ReadOnly="true" runat="server" MaxLength="50" CssClass="text ui-widget-content ui-corner-all"></asp:TextBox>
                         
                       </td>

                    </tr>

                      <tr>
                        <th width="20%">委外出厂工序ID：
                        </th>
                        <td width="30%">
                            <asp:TextBox ID="txtOutProcessID" ReadOnly="true" runat="server" MaxLength="50" CssClass="text ui-widget-content ui-corner-all"></asp:TextBox>
                            <asp:HiddenField id="hdOutOrderNum" runat="server"/>
                        </td>
                        <th width="20%">委外回厂工序ID：
                        </th>
                        <td width="30%">
                            <asp:TextBox ID="txtBackProcessID" ReadOnly="true" runat="server" MaxLength="50" CssClass="text ui-widget-content ui-corner-all"></asp:TextBox>
                             <asp:HiddenField id="hdBackOrderNum" runat="server"/>
                        </td>

                    </tr>
                    <tr>
                        <th width="20%">回厂料号：
                        </th>
                        <td width="30%">
                             <asp:TextBox ID="txtBackMaterialID" ReadOnly="true" runat="server" MaxLength="50" CssClass="text ui-widget-content ui-corner-all"
                                Width="90%"></asp:TextBox>
                             <asp:RequiredFieldValidator ID="rfvBackMaterialID" runat="server" ErrorMessage="请选择回厂料号！"
                                ControlToValidate="txtBackMaterialID" Display="None" ValidationGroup="gSubmit">
                            </asp:RequiredFieldValidator>
                            <span style="color: Red">*</span>
                            <a onclick="ShowTopDialog('料号选择', '../ComPage/QueryMBOMMaterial.aspx','FillBackMaterialID();',1000,550);return false;"
                                >
                                <img src="../App_Themes/Common_CSS/images/GridDetail.gif" alt="" />
                            </a>
                            <asp:Button ID="btnSelectBackMaterial" runat="server" CssClass="Hidden" OnClick="btnSelectBackMaterial_Click" />
                        </td>
                        <th>回厂品名：
                        </th>
                        <td>
                            <asp:TextBox ID="txtBackMaterialName" ReadOnly="true" runat="server" MaxLength="15" CssClass="text ui-widget-content ui-corner-all "></asp:TextBox>
                        </td>
                    </tr>

                    <tr>
                        <th width="20%">回厂数量：
                        </th>
                        <td width="30%">
                            <asp:TextBox ID="txtBackNums" runat="server" MaxLength="50" CssClass="text ui-widget-content ui-corner-all"
                                Width="90%"></asp:TextBox>
                            <asp:RegularExpressionValidator ControlToValidate="txtBackNums" Display="None" ErrorMessage="回厂数量，请填写数字" ID="revOutSide"
                                ValidationExpression="\d{0,9}(\.\d{0,2})?" ValidationGroup="gSubmit" runat="server"></asp:RegularExpressionValidator>

                        </td>
                        <th>加工费：
                        </th>
                        <td>
                            <asp:TextBox ID="txtProcessCost" runat="server" MaxLength="50" CssClass="text ui-widget-content ui-corner-all"
                                Width="90%"></asp:TextBox>
                            <asp:RegularExpressionValidator ControlToValidate="txtProcessCost" Display="None" ErrorMessage="加工费，请填写数字" ID="revProcessCost"
                                ValidationExpression="\d{0,9}(\.\d{0,2})?" ValidationGroup="gSubmit" runat="server"></asp:RegularExpressionValidator>

                        </td>
                    </tr>

                    <tr id="isEnd">
                        <th width="20%">是否结案：
                        </th>
                        <td width="30%">
                            <asp:CheckBox ID="txtIsFinish" runat="server" Enabled="false"  />
                        </td>
                        <th></th>
                        <td></td>
                    </tr>

                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <div class="tableStyle">





        <div id="tabs">
            <ul>
                <li><a href="#tabs-1">出厂材料明细</a></li>
            </ul>
          
          

            <div id="tabs-1" class="tableStyle" style="padding-bottom: 0px; margin-bottom: 0px; margin-left: 10px; margin-right: 10px; padding-left: 0px; padding-right: 0px;">
                <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                    <ContentTemplate>

                        <div class="divscroll" style="padding-bottom: 0px; width: 100%; float: left">
                            <asp:SGridView runat="server" ID="grdResult" Width="100%" ShowActionToolBar="false"
                                OnRowDataBound="grdResult_RowDataBound" OnRowCommand="grdResult_RowCommand" AutoGenerateColumns="false"
                                AllowCascade="false" BorderWidth="1" BorderColor="#c0c0c0">
                                <Columns>
                                    <asp:TemplateField HeaderText="序号">
                                        <ItemTemplate>
                                            <%# Container.DisplayIndex+1 %>
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField>
                                        <HeaderTemplate>
                                            原料编号
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="lblMaterialID" runat="server" Text='<%# Eval("MaterialID") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField>
                                        <HeaderTemplate>类别</HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="lblMaterialTypeName" runat="server" Text='<%#  Eval("MaterialTypeName") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>


                                    <asp:TemplateField>
                                        <HeaderTemplate>品名</HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="lblsMaterialName" runat="server" Text='<%#  Eval("MaterialName") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField>
                                        <HeaderTemplate>规格</HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="txtSpecifications" runat="server" Text='<%#  Eval("Specifications") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField>
                                        <HeaderTemplate>单位</HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="txtUnit" runat="server" Text='<%#  Eval("Unit") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>



                                    <asp:TemplateField>
                                        <HeaderTemplate>
                                            发料数量
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtNums" Text='<%# Eval("Nums") %>' runat="server"></asp:TextBox>
                                              <asp:RegularExpressionValidator ControlToValidate="txtNums" Display="None" ErrorMessage="发料数量，请填写数字" ID="revProcessCost"
                                ValidationExpression="\d{0,9}(\.\d{0,2})?" ValidationGroup="gSubmit" runat="server"></asp:RegularExpressionValidator>
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                </Columns>
                            </asp:SGridView>

                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>

            </div>
        </div>
    </div>
    <div class="controlBar" align="center">
        <table cellpadding="0" cellspacing="0" style="width: 140px; margin: 0 auto;">
            <tr>
                <td colspan="4">
                    <label class="btnStyleb png_bg">
                        <asp:Button ID="btnSubmit" runat="server" Text="保存" OnClick="btnSubmit_Click" ValidationGroup="gSubmit"
                            class="png_bg" />
                    </label>
                    <label class="btnStylec png_bg">
                        <input type="button" id="btnCancel" value="返回" runat="server" onclick="window.location = 'OutOrderList.aspx'"
                            class="png_bg" />
                    </label>
                </td>
            </tr>
        </table>
    </div>
  
</asp:Content>
